package com.thyme.controller;

import com.thyme.config.FastDFSClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author thyme
 * @ClassName TestController
 * @Description TODO
 * @Date 2020/4/24 17:25
 */
@RestController
public class TestController {

    @Autowired
    private FastDFSClient fastDFSClient;

    @RequestMapping("/upload")
    public String upload(@RequestParam("file")MultipartFile file){
        String s = null;
        try {
            s = fastDFSClient.uploadFule(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    @RequestMapping("/delete")
    public Boolean delete(@RequestParam("url") String url) {
        return fastDFSClient.deleteFile(url);
    }
}
